fix: atomic dataset unlink via RPC, resolve dedup callbacks, guard metadata fetch errors, harden null count check - #79
Merged
Merged
Conversation
…tadata fetch errors, harden null count check
There was a problem hiding this comment.
Pull request overview
This PR addresses dataset deduplication and lifecycle handling in canvas contexts so the same dataset can be reused across canvases, and introduces an RPC to unlink datasets atomically (with optional cleanup) while hardening a few client-side error paths.
Changes:
- Removed dataset creation-time filename deduplication and moved dedup/reuse logic into
useDatasetManager(including cross-canvas reuse by linking an existing completed dataset). - Added an atomic “unlink + conditional delete” flow via a new Postgres RPC and switched canvas dataset removal to use it.
- Improved robustness: resolve progress/status callbacks on dedup early-returns, log realtime subscription failures, and guard metadata fetch errors before metadata merge updates.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| frontend/lib/services/datasetService.ts | Removes create-time dedup; adds canvas link/unlink helpers and RPC-based remove-from-canvas. |
| frontend/hooks/useDatasetManager.ts | Implements canvas/global dedup and reuse, updates deletion behavior on canvases, and adds realtime subscription error logging. |
| backend/database/schema.sql | Enables Realtime for canvas_datasets and adds unlink_dataset_from_canvas RPC for atomic unlink + conditional delete. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
frontend/hooks/useDatasetManager.ts:237
- The lines starting the actual upload lifecycle (
onStatusChange?.('pending'),onProgress?.(10), and thecreateDatasetcall) are mis-indented relative to the surroundingtry { ... }block, which makes the control flow harder to read and easy to misinterpret during maintenance. Run the formatter / fix indentation to match the rest of the file.
// Step 1: Create dataset with pending status
onStatusChange?.('pending');
onProgress?.(10);
const dbDataset = await DatasetService.createDataset({
userId,
filename: file.name,
fileSize: file.size,
fileType: file.type || 'text/csv',
});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of Change
Related Issues
Closes #75
Changes Made
Checklist
Additional Context